package dailearn.producer.controller;

import dailearn.producer.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author daify
 * @date 2019-07-13
 */
@RestController
@Slf4j
public class UserController {

    @RequestMapping(value = "user",method = RequestMethod.GET)
    public String getUserInfo(User user) {
        log.info("userInfo: name-{},age-{}",user.getName(),user.getAge());
        return user.getName() + "---" + user.getAge();
    }


    @RequestMapping(value = "getNumber",method = RequestMethod.GET)
    public String getNumber(Integer number) {
        log.info("number:{}",number);
        return String.valueOf(number);
    }


    @RequestMapping(value = "getStr",method = RequestMethod.GET)
    public String getStr(String str) {
        log.info("String:{}",str);
        return str;
    }

    @RequestMapping(value = "getStrV2",method = RequestMethod.GET)
    public String getStrV2(String str) {
        log.info("getStrV2:{}",str);
        return str;
    }

    @RequestMapping(value = "getNone",method = RequestMethod.GET)
    public String getNone() {
        log.info("getNone:getNone");
        return "getNone";
    }


    @RequestMapping(value = "/simple/{id}",method = RequestMethod.GET)
    public String getId(@PathVariable(required = false) Long id) {
        log.info("getId:{}",id);
        return String.valueOf(id);
    }
}
